package com.yctan.base.utils.exception;

import com.yctan.base.entity.R;
import org.apache.commons.logging.Log;

import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.Response;

/**
 * @Author
 * @Date 2019/5/4 12:05
 * @Description
 */
public class ExceptionHandle {
    public R exceptionHandler(Exception e, HttpServletResponse response, Log logger){
       // ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
       // HttpServletResponse response = attributes.getResponse();
        response.setStatus(300);
        if(e instanceof MyError){
            CustomizeException exception = (CustomizeException) e;
            logger.error(Log4jInfo.HEAD+exception.getResponse().toString());
            return exception.getResponse();
        }
        logger.error(Log4jInfo.HEAD+e.getMessage());
        return R.error("系统异常",response);
    }
}
